from django.test import TestCase
from django.utils.decorators import classonlymethod
# Create your tests here.

'''
class T():
    def __init__(self,name,age):
        self.name = name
        self.age = age

    @classmethod    # sleeping  = classmethod(sleeping)
    def sleeping(cls):
        print("T is sleeping")

    @classonlymethod
    def guangjie(cls):
        print("xx is shopping")

    print(sleeping)
xx = T('tansi',18)
xx.sleeping()
# xx.guangjie()
T.guangjie()
'''

"""
# hasattr getattr setattr
class TS:
    def __init__(self,name,age,gender):
        self.name = name
        self.age = age
        self.gender = gender

    def change(self):
        print("ts is chaned")

    def show_self(self):
        print(self)


class QQ(TS):
    pass

ts = TS('tansi',19,'male')
qq = QQ('qq',1,'female')
qq.show_self()
"""
# print(ts.__dict__)
# print(ts.name)
# print(hasattr(ts,'name'))   # True
# print(hasattr(ts,'age'))
# print(hasattr(ts,'change'))
# print(hasattr(ts,'hobby'))  # False
#
# setattr(ts,"hobby",['change'])
# print(hasattr(ts,'hobby'))      # True
#
# ret = getattr(ts,'hobby')
# print(ret)

'''
import time

def outer(func):
    def inner(*args,**kwargs):
        start_time = time.time()
        ret = func(*args,**kwargs)
        time.sleep(0.1)
        end_time = time.time()
        used_time = end_time - start_time
        print(used_time)
        return ret
    return inner

@outer
def add(x,y):
    return x + y

x = add(1,2)
print(x)
'''
'''
class X:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __getattr__(self, item):    # 这个方法再属性没有被找到的时候执行
        raise AttributeError("这个属性不存在")

x = X('tansi',18)
print(x.hobby)
'''

'''
class Q:
    def __init__(self):
        print("qqq")

class X(Q):
    def __init__(self):
        print("xxx")
        Q.__init__(self)

x = X()
'''

"""
# 动态导入模块
import  importlib

module = input("请输入要导入的模块>>>>>>>")
module = importlib.import_module(module)
module.foo()
"""
'''
a = 1
b = 2
c = a if a>b else b
print(c)
'''


class Animal:
    def eat(self):
        print("Eating")
    def yuan(self):
        print("Yuan")
    def sleeping(self):
        print("Sleeping")

class WangWang:
    def wangwang(self):
        print("wangwang")

class Flying:
    def flying(self):
        print("flying")

class Don(Animal, WangWang):
    pass


class Bird(Animal, Flying):
    pass

class Person(Animal):
    pass




